// A6. Cross-Sectional Relationship Between Preprimary Enrollment and Outcomes
// A6. Cross-Sectional Relationship Between Preprimary Enrollment and Outcomes
// A6. Cross-Sectional Relationship Between Preprimary Enrollment and Outcomes


// PRELIMINARIES

clear
set more off
set scheme s1mono



// LOAD DATA
	
use "JakielaOzierFernaldKnauer-preschool-data.dta", replace


// Panel A no controls

local outcome1 zluovocab
local outcome2 zengvocab
local outcome3 zexpvocab
local outcome4 zmotor
local outcome5 ecdindex


forvalues i = 1/5 {
	regress `outcome`i'' inschool if roundage==3, cluster(respid)
	mat V = r(table)
	local _beta`i' = string(V[1,1],"%04.3f")
	local _se`i' = string(V[2,1],"%04.3f")
	local _pval`i' = string(V[4,1],"%04.3f")
	if V[4,1] < 0.001 {
		local _pval`i' = "p$<$0.001"
	}
	local _obs`i' = e(N)
	local _r2`i' = string(e(r2),"%04.3f")
}

cap file close fh
file open fh using "out/A6A-biasedols1.tex", write replace

file write fh "Enrolled in preprimary  & `_beta1' & `_beta2' & `_beta3' & `_beta4' & `_beta5' \\ " _newline
file write fh "		    & (`_se1') & (`_se2') & (`_se3') & (`_se4') & (`_se5') \\ " _newline
file write fh "		    & [`_pval1'] & [`_pval2'] & [`_pval3'] & [`_pval4'] & [`_pval5']  \\ " _newline

file close fh


// Panel B covariate adjusted


local controls "i.childage haz male cgmom momeduc momluo hhsize sibs numassets haz_imputed dadabsent dadeduc dadluo missing_data i.schoolid"

forvalues i = 1/5 {
	regress `outcome`i'' inschool `controls' if roundage==3, cluster(respid)
	mat V = r(table)
	local _beta`i' = string(V[1,1],"%04.3f")
	local _se`i' = string(V[2,1],"%04.3f")
	local _pval`i' = string(V[4,1],"%04.3f")
	if V[4,1] < 0.001 {
		local _pval`i' = "p$<$0.001"
	}
	local _obs`i' = e(N)
	local _r2c`i' = string(e(r2),"%04.3f")
}

cap file close fh
file open fh using "out/A6B-biasedols2.tex", write replace

file write fh "Enrolled in preprimary  & `_beta1' & `_beta2' & `_beta3' & `_beta4' & `_beta5' \\ " _newline
file write fh "		     & (`_se1') & (`_se2') & (`_se3') & (`_se4') & (`_se5') \\ " _newline
file write fh "		     & [`_pval1'] & [`_pval2'] & [`_pval3'] & [`_pval4'] & [`_pval5']  \\ " _newline

file close fh




cap file close fh
file open fh using "out/A6-biasedolsinfo_r2noc.tex", write replace
file write fh "\$R^2\$ & `_r21' & `_r22' & `_r23' & `_r24' & `_r25'  \\  " _newline
file close fh


cap file close fh
file open fh using "out/A6-biasedolsinfo_r2c.tex", write replace
file write fh "\$R^2\$ & `_r2c1' & `_r2c2' & `_r2c3' & `_r2c4' & `_r2c5'  \\  " _newline
file close fh


cap file close fh
file open fh using "out/A6-biasedolsinfo_obs.tex", write replace
file write fh "Obs.  & `_obs1' & `_obs2' & `_obs3' & `_obs4' & `_obs5'  \\  " _newline
file close fh
